﻿using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class HealthPanel : MonoBehaviour
{
    private TextMeshProUGUI _owner;
    private Image _ageLimit;

    void Start()
    {
        _owner = transform.Find("Owner").GetComponent<TextMeshProUGUI>();
        _ageLimit = transform.Find("AgeLimit").GetComponent<Image>();
        _owner.text = $"{AdManager.Owner}\n{AdManager.License}";

        switch (AdManager.AgeLimit)
        {
            case 8:
                _ageLimit.sprite = Resources.LoadAll<Sprite>("Sprites/Common/AgeLimit")[0];
                break;

            case 12:
                _ageLimit.sprite = Resources.LoadAll<Sprite>("Sprites/Common/AgeLimit")[1];
                break;

            case 16:
                _ageLimit.sprite = Resources.LoadAll<Sprite>("Sprites/Common/AgeLimit")[2];
                break;

            default:
                _ageLimit.sprite = Resources.LoadAll<Sprite>("Sprites/Common/AgeLimit")[2];
                break;
        }

        Invoke("LoadScene", 2);
    }

    private void LoadScene()
    {
        SceneManager.LoadScene(Constants.StartScene);
    }
}